﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Weazel.Math;

#endregion

namespace Weazel.Math.Test
{
  [TestClass]
  public class TestGetStringType
  {
    [TestMethod]
    public void TestGetStringTypeInvalidFormatNotANumber()
    {
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType("this is an invalid string"));
    }

    [TestMethod]
    public void TestGetStringTypeInvalidFormatEmptyString()
    {
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType(""));
    }

    [TestMethod]
    public void TestGetStringTypeInvalidFormatSingleCharacter()
    {
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType("-"));
    }

    [TestMethod]
    public void TestGetStringTypeInvalidFormatInvalidCharacter1()
    {
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType("120A")); // decimal
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType("-120A"));
    }

    [TestMethod]
    public void TestGetStringTypeInvalidFormatInvalidCharacter2()
    {
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType("0xFFG")); // hex
    }

    [TestMethod]
    public void TestGetStringTypeInvalidFormatInvalidCharacter3()
    {
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType("0b12")); // binary
    }

    [TestMethod]
    public void TestGetStringTypeInvalidFormatInvalidCharacter4()
    {
      Assert.AreEqual(Integer.StringType.Invalid, Integer.GetStringType("012NOTOCTAL")); // octal
    }


    [TestMethod]
    public void TestGetStringTypeOctal()
    {
      Assert.AreEqual(Integer.StringType.Octal, Integer.GetStringType("012345")); 
    }
    [TestMethod]
    public void TestGetStringTypeBinary()
    {
      Assert.AreEqual(Integer.StringType.Binary, Integer.GetStringType("0b11101")); 
    }
    [TestMethod]
    public void TestGetStringTypeHexadecimal()
    {
      Assert.AreEqual(Integer.StringType.Hexadecimal, Integer.GetStringType("0xFFF")); 
    }

    [TestMethod]
    public void TestGetStringTypeDecimal()
    {
      Assert.AreEqual(Integer.StringType.Decimal, Integer.GetStringType("10"));
      Assert.AreEqual(Integer.StringType.Decimal, Integer.GetStringType("-120"));
    }
  }
}
